package com.liurz.jpa.test;

import lombok.Data;
import org.springframework.util.StringUtils;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@Entity
@Table(name = "ticket")
@Data
public class Ticket implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -7204574552886998992L;
	@Id
	@Column(length = 50)
	private String guid;
	@Column
	private String ticketNum;
	@Column
	private String reportUnit; //上报单位
	@Column
	private String reportTime; //上报时间
	@Column
	private String name;  // 事件名称
	@Column
	private String eventType;  // 事件类型
	@Column
	private String originTime;//起始时间
	@Column
	private String expireTime;  // 到期时间(一人多证)
	@Column
	private String alarmIp;     // 告警ip、源ip
	@Column
	private String netIp;         // 互联网ip、目的ip

	@Column(length = 2048)
	private String provinces;   // 逗号分隔的多省任务，不为空(provincesID)
	@Column
	private String currentState;//当前状态
	@Column(length = 2048)
	private String provincesName; //逗号分隔 //省的名称
	@Column
	private String ticketInflunce;  // 严重程度
	@Column
	private String feedback;     // 是否反馈 yes:是;no：否
	@Column
	private String createUser;      // 上报人
	@Column
	private String createUserID;
	@Column
	private String startTime;       //上报时间、下发时间
	@Column
	private String endTime;
	@Column
	private String planTime;       // 计划时间
	//@Column(columnDefinition="JSON")
	@Column(length = 3999)
	private String addContent;     // 多属性json格式存储
	@Column(length = 500)
	private String ticketDescr;     // 标准事件内容
	@Column(length = 250)
	private String assignPeople; //抄送人
	@Column
	private String assignPeopleName; //抄送人名称、
	@Column
	private String state;  // 待上报，办结，审核办理不通过
	@Column
	private String processInstanceId; //流程实例ID
	@Column
	private String processKey; //流程类型
	@Column
	private String finishTime;//办结时间
	@Column
	private String regionCount;//涉及单位数
	@Column
	private String approvalType;//审批类型 （1:副指挥长审批，2:指挥长审批,3:两级审批）
	@Column
	private String downTime;//下发时间
	@Column
	private String emergencyUpPersion;//应急上报人

	public List<String> getProvinceList(){
		if(StringUtils.isEmpty(provinces)) {
			return Collections.emptyList();
		}
		
		return Arrays.asList(provinces.split(","));
	}
}
